﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace StockShark.Models
{
    // wykonane transakcje kupna/sprzedazy
    public class ExecutedTransaction
    {
        public int Id { get; set; }
        public int BrokerageAccountId { get; set; }
        public int PaperId { get; set; }
        public int Quantity { get; set; }
        public decimal UnitPrice { get; set; }
        public decimal Commission { get; set; }
        public bool BuyNotSell { get; set; }
        [DisplayFormat(DataFormatString = "{0:g}")]
        public DateTime ExecutionDate { get; set; }
        public virtual Instrument Paper { get; set; }
        public virtual BrokerageAccount BrokerageAccount { get; set; }

        public decimal BalanceChange
        {
            get
            {
                return (Quantity * UnitPrice) * (BuyNotSell ? -1 : 1) - Commission;
            }
        }
    }
}